﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QLTH_DTO;
using QLTH_BUSINESS;
using unitlControl;


namespace QuanLy_THPT_S4.TienIch
{
    public partial class frmQLNguoiDung : Form
    {
        private readonly clsQLNguoiDungDTO _nd;
        private readonly clsQLNguoiDungBU _ndBU;
        private readonly clsPhanQuyenBU _pqBU;
        private readonly clsGIaoVienBU _gvBU;
        public frmQLNguoiDung()
        {
            InitializeComponent();
                _nd = new clsQLNguoiDungDTO();
                _ndBU = new clsQLNguoiDungBU();
                _pqBU = new clsPhanQuyenBU();
                _gvBU = new clsGIaoVienBU();
        }

        private void frmQLNguoiDung_Load(object sender, EventArgs e)
        {
       
           ComboUtils.SetDataSuorce(cmbQuyenDN, _pqBU.DanhSachPQ(), "MAPQ", "TENQUYEN", 0);
           ComboUtils.SetDataSuorce(cmbGV, _gvBU.DanhSachGiaoVien(), "MAGV", "HOTEN", 0);
           gridControl1.DataSource = _ndBU.DanhSachND();
           radioGroup1.EditValue = true;
        }

        private void btnThemND_Click(object sender, EventArgs e)
        {
            _nd.Gv.Magv = ComboUtils.LayGT_Combobox(cmbGV);
            _nd.Pq.Mapq = ComboUtils.LayGT_Combobox(cmbQuyenDN);
            _nd.Tendn = txtTenDN.Text;
            _nd.Matkhau = toancuc.GetMd5(txtMatkhau.Text);
            _nd.Trangthai =int.Parse(radioGroup1.EditValue.ToString());
            _ndBU.Them_nguoidung(_nd);
            frmQLNguoiDung_Load(sender, e);
        }

        private void cmbQuyenDN_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

     
    }
}
